//
//  UIKitButton.swift
//  Extensions
//
//  Created by gupengling on 2021/6/5.
//  Copyright © 2021 gupengling. All rights reserved.
//

import UIKit

public extension Array where Element: NSObject {
    public mutating func remove(object: Element) {
        if let index = self.firstIndex(of: object) {
            self.remove(at: index)
        }
    }
}

//public extension Array {
//    subscript(safe index: Int) -> Element? {
//        return indices ~= index ? self[index] : .none
//    }
//}
public extension Collection {
    public subscript(safe index: Index) -> Element? {
        return indices.contains(index) ? self[index] : nil
    }
}
